#include "threadPool.hpp"
#include "Task.hpp"
#include <ctime>
#include <cstdlib>
#include "log.hpp"

int main()
{
    srand((u_int64_t)time(nullptr) ^ getpid());
    // ThreadPool<Task>* tp = new ThreadPool<Task>();
    ThreadPool<Task>* tp = ThreadPool<Task>::getThreadPool();

    tp->run();
    while(true)
    {
        int x = rand() % 100 + 1;
        usleep(5234);
        int y = rand() % 30 + 1;
        Task t(x, y, [](int x,int y)->int{
            return x + y;
        }
        );
        // std::cout << "制作任务完成：" << x << "+" << y << "=?" << std::endl;
        logMessage(DEBUG, "制作任务完成: %d+%d=?", x, y);
        //推送任务的线程池中
        tp->pushTask(t);
        sleep(1);
    }
    return 0;
}